﻿Imports Microsoft.VisualStudio.TestTools.UnitTesting

Imports paycircuit.com.google.iap



'''<summary>
'''This is a test class for InAppItemSubscriptionRequestObjectTest and is intended
'''to contain all InAppItemSubscriptionRequestObjectTest Unit Tests
'''</summary>
<TestClass()> _
Public Class InAppItemSubscriptionRequestObjectTest

    Const MY_SELLER_ID As String = "YOUR_SELLER_ID" ' "YOUR SELLER ID"
    Const MY_SELLER_SECRET As String = "YOUR_SELLER_SECRET" ' "YOUR SELLER SECRET"
    Const MY_POSTBACK_TYP As String = "google/payments/inapp/item/v1/postback/buy"
    Const THE_ISSUER As String = "Google"

    Private testContextInstance As TestContext

    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(value As TestContext)
            testContextInstance = value
        End Set
    End Property

#Region "Additional test attributes"
    '
    'You can use the following additional attributes as you write your tests:
    '
    'Use ClassInitialize to run code before running the first test in the class
    '<ClassInitialize()>  _
    'Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
    'End Sub
    '
    'Use ClassCleanup to run code after all tests in a class have run
    '<ClassCleanup()>  _
    'Public Shared Sub MyClassCleanup()
    'End Sub
    '
    'Use TestInitialize to run code before running each test
    '<TestInitialize()>  _
    'Public Sub MyTestInitialize()
    'End Sub
    '
    'Use TestCleanup to run code after each test has run
    '<TestCleanup()>  _
    'Public Sub MyTestCleanup()
    'End Sub
    '
#End Region


    '''<summary>
    '''A test for InAppItemSubscriptionRequestObject Constructor         
    '''</summary>
    <TestMethod()> _
    Public Sub InAppItemSubscriptionRequestObjectConstructorTest()

        Dim request As New InAppItemSubscriptionRequestObject() With {.name = "Weekly Cake", .description = "Virtual chocolate cake to fill your virtual tummy every week",
                                                                      .initialPayment = New InAppSubscriptionInitialPaymentObject() With
                                                                                        {
                                                                                            .price = "10.50", .currencyCode = RequestObject.SupportedCurrencies.USD.ToString(), .paymentType = "prorated"
                                                                                                                                 },
                                                                      .recurrence = New InAppSubscriptionRecurrenceObject() With
                                                                                    {
                                                                                        .frequency = "monthly",
                                                                                        .price = "4.99",
                                                                                        .currencyCode = "USD"
                                                                                    }
                                                                     }

        Dim target As InAppItemObject = New InAppItemObject(request)

        target.iss = MY_SELLER_ID
        ' target.response = New InAppItemResponseObject()
        Dim actual = JSONHelpers.dataContractToJSON(target)
        Assert.IsTrue(Not String.IsNullOrEmpty(actual))
        Assert.Inconclusive(String.Format("JSON with default values: {0}", actual))
    End Sub

    <TestMethod()> _
    Public Sub InAppItemSubscriptionRequestObjectConstructorTestWtihRecurrence()

        Dim request As New InAppItemSubscriptionRequestObject() With {.name = "Weekly Cake", .description = "Virtual chocolate cake to fill your virtual tummy every week",
                                                                      .initialPayment = New InAppSubscriptionInitialPaymentObject() With
                                                                                        {
                                                                                            .price = "10.50", .currencyCode = RequestObject.SupportedCurrencies.USD.ToString(), .paymentType = "prorated"
                                                                                                                                 },
                                                                      .recurrence = New InAppSubscriptionRecurrenceObject() With
                                                                                    {
                                                                                        .frequency = "monthly",
                                                                                        .price = "4.99",
                                                                                        .currencyCode = "USD",
                                                                                        .recurrenceStartDate = New DateTime(2013, 11, 15),
                                                                                        .numRecurrences = "12"
                                                                                    }
                                                                     }

        Dim target As InAppItemObject = New InAppItemObject(request)

        target.iss = MY_SELLER_ID
        ' target.response = New InAppItemResponseObject()
        Dim actual = JSONHelpers.dataContractToJSON(target)
        Assert.IsTrue(Not String.IsNullOrEmpty(actual))
        Assert.Inconclusive(String.Format("JSON with default values: {0}", actual))
    End Sub
End Class
